package com.mastercard.assets.web.struts.actions;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.mastercard.assets.util.dao.MCCatalogs;
import com.mastercard.assets.util.dao.MasterCardDAO;
import com.mastercard.assets.web.struts.forms.LoginForm;

public class Login
	extends
		Action
{
	public ActionForward execute(
							ActionMapping mapping , 
							ActionForm form ,
							HttpServletRequest request , 
							HttpServletResponse response )
		throws 
			IOException , 
			ServletException
	{
		// convierte el form
		LoginForm f = ( LoginForm ) form ;
		
		getServlet( ).getServletContext( ).setAttribute( "MCCatalogs" , MCCatalogs.getCatalogs( ) ) ;
		
                MasterCardDAO.closeEntityManager( ) ;
	  	return mapping.findForward( "success" ) ;
	}
	
}
